package study06;

import java.util.concurrent.Executors;
import java.util.concurrent.ExecutorService;

public class Java05_Thread_pool {
    public static void main (String arg[]) throws Exception {
//        1、线程 - 线程池
//        ExecutorService executorService = Executors.newFixedThreadPool(3);

//        2、根据需求动态创建线程
//        ExecutorService executorService = Executors.newCachedThreadPool();

//        3、单一线程
//        ExecutorService executorService = Executors.newSingleThreadExecutor();

//        4、定时调度的线程
        ExecutorService executorService = Executors.newScheduledThreadPool(3);

        for (int i = 0; i < 5; i++) {
            executorService.submit(new Runnable() {
                @Override
                public void run() {
                    System.out.println(Thread.currentThread().getName());
                }
            });
        }
    }
}
